<template>
  <div class="detail-swiper">
    <swiper :imgLoaded="imgLoaded" class="swiper">
      <swiper-item slot="slide" v-for="(item, index) in swiperImgs" :key="index">
        <img :src="item" @load="itemLoaded" />
      </swiper-item>
    </swiper>
  </div>
</template>

<script>
  import Swiper from '@commoncpn/swiper/Swiper.vue'
  import SwiperItem from '@commoncpn/swiper/SwiperItem.vue'

  export default {
    name: 'detail-swiper',
    components: { Swiper, SwiperItem },
    data() {
      return {
        imgLoaded: false
      }
    },
    props: {
      swiperImgs: {
        type: Array,
        default() {
          return []
        }
      }
    },
    methods: {
      itemLoaded() {
        this.imgLoaded = true
        this.$emit('imgloaded')
      }
    }
  }
</script>

<style lang="less" scoped>
  .swiper {
    height: 200px;
  }
</style>
